package cc.comac.mom.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.mom.api.EquipFaultCauseService;
import cc.comac.mom.bean.EquipFaultCause;
import cc.comac.mom.bean.ResultDev;
import cc.comac.mom.util.ResultBean;

@RestController
@RequestMapping("/EquipFaultCause")
public class EquipFaultCauseController {

	@Autowired
	private EquipFaultCauseService equipFaultCauseService;
	
	
	@RequestMapping(value = "/insertFaultCause",method = RequestMethod.POST)
	public ResultBean insertFaultCause(@RequestBody EquipFaultCause equipFaultlCause) {
			ResultBean resultBean = equipFaultCauseService.insertFaultCause(equipFaultlCause);
		return resultBean;
	}
	@RequestMapping(value = "/updateFaultCause",method = RequestMethod.POST)
	public ResultBean updateFaultCause(@RequestBody EquipFaultCause equipFaultlCause) {
		
			ResultBean updateFaultCause = equipFaultCauseService.updateFaultCause(equipFaultlCause);
		return updateFaultCause;
	}
	@RequestMapping(value = "/batchDelete",method = RequestMethod.POST)
	public ResultBean batchDelete(@RequestBody List<EquipFaultCause> list) {
			ResultBean batchDelete = equipFaultCauseService.batchDelete(list);
		return batchDelete;
	}
	@RequestMapping(value = "/selectSomeField",method = RequestMethod.POST)
	public ResultBean selectSomeField (@RequestBody EquipFaultCause equipFaultlCause) {
		ResultBean resultBean = new ResultBean(true);
		try {
			ResultDev selectSomeField = equipFaultCauseService.selectSomeField(equipFaultlCause);
			resultBean.setObject(selectSomeField);
		} catch (Exception e) {
			resultBean.setErrorMessge(e.getMessage());
		}
		return resultBean;
	}
	
	@RequestMapping(value = "/selectAll",method = RequestMethod.POST)
	public ResultBean selectAll() {
		ResultBean resultBean = new ResultBean(true);
		ResultDev selectAll = equipFaultCauseService.selectAll();
		resultBean.setObject(selectAll);
		return resultBean;
	}
}
